		<?php
			session_start();
			require_once("functions.php");
			//require_once("addLeaveForm.php");
			require_once("LeaveFormController.php");
			$errorFlag = 0;
			$dateOfFiling = $_POST['dateOfFiling'];			
			$dateReceived = $_POST['dateReceived'];
			$dFError = false;
			$dRError = false;
			$dRError2 = false;
			
			$employeeNumber = $_POST['employeeNumber'];
			$typeOfLeave = $_POST['typeOfLeave'];
			//$gender = $_POST['gender'];
					
			$link = makeSQLconnection();
			$q = sprintf("SELECT * from `EMPLOYEE` where Employee_number = '$employeeNumber'");
			$r = mysql_query($q, $link);
			$data = mysql_fetch_assoc($r);
			$gender = $data['Employee_gender'];
			mysql_close($link);
			
			$tLError = false;
			
			$typeOfError = "";
			$daysComputed = 1;
			$days = $_POST['days'];
			$daysError = false;
			$daysError2 = false;			
			$daysError3 = false;			
			$daysError3 = false;			
			
			$startDate = $_POST['startDate'];			
			$sDError = false;
			$sDError2 = false;
		
			$endDate = $_POST['endDate'];			
			$eDError = false;
			$eDError2 = false;
			$eDError3 = false;
			
			$status = $_POST['status'];
			$sError = false;
			$link = makeSQLconnection();
			
			//ibig sabihin may nilagay siya sa date of filing
			if ($dateOfFiling) {
				$result1 = checkFormat($dateOfFiling);
				$dFyear = substr($dateOfFiling, 6,10);
				$dFmonth = substr($dateOfFiling, 0, 2);
				$dFday = substr($dateOfFiling, 3,-5);	

				if	($result1) {		
					$result = validateDate ($dFmonth, $dFday, $dFyear);		
					
					if	(!$result) {
						
						$dFError = true;
						$errorFlag = 1;			
					}
					
				} else {
					$errorFlag = 1;
					$dFError = true;					
				}						
			}
			
			if ($dateReceived) {
				$result1 = checkFormat($dateReceived);
				$dRyear = substr($dateReceived, 6,10);
				$dRmonth = substr($dateReceived, 0, 2);
				$dRday = substr($dateReceived, 3,-5);	

				if	($result1) {		
					$result = validateDate ($dRmonth, $dRday, $dRyear);		
					
					if	(!$result) {
						
						$dRError = true;
						$errorFlag = 1;			
					}
					
				} else {
					$errorFlag = 1;
					$dRError = true;					
				}
			}
					
			if ($dateReceived && $dateOfFiling) {
				if ($dFyear > $dRyear) {
					//02 29 2009 && 02 06 2008
					$errorFlag = 1;
					$dRError2 = true;				
				} else if ($dFyear == $dRyear) {
					//02 01 2009 && 02 06 2009					
					if ($dFmonth > $dRmonth) {
						//02 02 2008 && 01 06 2008
						$errorFlag = 1;
						$dRError2 = true;
					} else if ($dFmonth == $dRmonth) {
						//02 21 2008 && 02 06 2008	
						if ($dFday > $dRday) {
							$errorFlag = 1;
							$dRError2 = true;
						}
					}
				}
			}
						
			//validate type of leave
			if($typeOfLeave == "null")
			{
				$errorFlag = 1;
				$tLError = true;
				
			}		
			
			//validate days
			if (strlen($days) == 0) {
				
				$errorFlag = 1;
				$daysError = true;	
			}
			
			$result1 = checkFormat($startDate);
			
			if	($result1) {
				$startYear = substr($startDate, 6,10);
				$startMonth = substr($startDate, 0, 2);
				$startDay = substr($startDate, 3,-5);
				
				$result = validateDate ($startMonth, $startDay, $startYear);				
				if	(!$result) {
					
					$sDError = true;
					$errorFlag = 1;
				}
			
			} else {
				
				$errorFlag = 1;
				$sDError = true;	
				
			}
				
			$result1 = checkFormat($endDate);
			
			if	($result1) {		
				$endYear = substr($endDate, 6,10);
				$endMonth = substr($endDate, 0, 2);
				$endDay = substr($endDate, 3,-5);
				
				$result = validateDate ($endMonth, $endDay, $endYear);						
				if	(!$result) {
					
					$eDError = true;
					$errorFlag = 1;			
				}
				
			} else {
				$errorFlag = 1;
				$eDError = true;					
			}

			if (!$sDError && !$eDError) {
				if ($startYear > $endYear) {
					//02 29 2009 && 02 06 2008
					$errorFlag = 1;
					$eDError2 = true;				
				} else if ($startYear == $endYear) {
					//02 01 2009 && 02 06 2009					
					if ($startMonth > $endMonth) {
						//02 02 2008 && 01 06 2008
						$errorFlag = 1;
						$eDError2 = true;
					} else if ($startMonth == $endMonth) {
						//02 21 2008 && 02 06 2008	
						if ($startDay > $endDay) {
							$errorFlag = 1;
							$eDError2 = true;
						}
					}
				}
			}
			
			//kapag may laman na ung database	
			$query1 = LeaveManager :: getLeaveData($_POST['employeeNumber'], "load");
			if ($query1) {
				if (mysql_num_rows($query1) != 0) {
				
					$result = dateChecker($startDate, $employeeNumber);
				
					if (!$result) {
						$sDError2 = true;
						$eDError3 = true;
						$errorFlag = 1;
					}
				}
			}		
				
			if($status == "null"){
				$errorFlag = 1;
				$sError = true;
			}		
			
			/**
			computation of days between start date and end date
			**/
						
			if ($typeOfLeave != 'TARDINESS' && $typeOfLeave != 'UNDERTIME') {
				if (!$sDError && !$eDError && !$eDError2) {
					
					$nextDate = $startYear."-".$startMonth."-".$startDay;
					$tempDate = $endYear."-".$endMonth."-".$endDay;
					
					if($nextDate != $tempDate){
				
						while(1) {
					
							$query = "SELECT INTERVAL 1 DAY + '".$nextDate."' AS nextDate";						
							$r2 = mysql_query($query, $link);
							$data1 = mysql_fetch_assoc($r2);
							
							$nextDateYear = substr($data1['nextDate'], 0, -6);
							$nextDateMonth = substr($data1['nextDate'], 5, -3);
							$nextDateDay = substr($data1['nextDate'], 8, 10);
							$nextDate = $nextDateYear."-".$nextDateMonth."-".$nextDateDay;
											
							$query = "SELECT DAYNAME('".$nextDateYear."-".$nextDateMonth."-".$nextDateDay."') AS dayOfWeek";
							$r1 = mysql_query($query, $link);						
							$data = mysql_fetch_assoc($r1);
						
							if ($data['dayOfWeek'] != "Saturday" && $data['dayOfWeek'] != "Sunday") {			
								
								++$daysComputed;
							}
							
							if ($endDay == $nextDateDay && $endMonth  == $nextDateMonth && $endYear == $nextDateYear) {
								break;
							}
						}
						
					}
					
					
					if ($daysComputed != $days) {
							$daysError2 = true;
							$errorFlag = 1;
					}
				}		
			} else {		
				if ($days >= 1) {
						$daysError = 1;
						$errorFlag = 1;
				}
			}
			
			if ($typeOfLeave == "SPECIAL") {
				
				$query = "SELECT * FROM `leaveform` WHERE `Type_of_leave` = '$typeOfLeave' and `Employee_number` = '$employeeNumber'";						
				$r2 = mysql_query($query, $link);
				$specialDays = 0;
								
				while($data1 = mysql_fetch_assoc($r2)) {
					$specialDays += $data1['Days'];					
				}
				
				if ($specialDays > 6) {
					$daysError3 = 1;
					$errorFlag = 1;
					$typeOfError = "special";
				}
				
			} else if ($typeOfLeave == "PATERNAL") {
				
				$query = "SELECT * FROM `leaveform` WHERE `Type_of_leave` = '$typeOfLeave' and `Employee_number` = '$employeeNumber'";						
				$r2 = mysql_query($query, $link);
				$paternityDays = 0;
								
				while($data1 = mysql_fetch_assoc($r2)) {
					$paternityDays += $data1['Days'];					
				}
				
				if ($paternityDays > 7) {
					$daysError3 = 1;
					$errorFlag = 1;
					$typeOfError = "Paternal Leave";
				}
			} else if ($typeOfLeave == "REHABILITATION") {
				
				$query = "SELECT * FROM `leaveform` WHERE `Type_of_leave` = '$typeOfLeave' and `Employee_number` = '$employeeNumber'";						
				$r2 = mysql_query($query, $link);
				$rehabDays = 0;
								
				while($data1 = mysql_fetch_assoc($r2)) {
					$rehabDays += $data1['Days'];					
				}
				
				if ($rehabDays > 120) {
					$daysError3 = 1;
					$errorFlag = 1;
					$typeOfError = "Rehabilitation Leave";
				}
			}  else if ($typeOfLeave == "FORCED") {
				
				$query = "SELECT * FROM `leaveform` WHERE `Type_of_leave` = '$typeOfLeave' and `Employee_number` = '$employeeNumber'";						
				$r2 = mysql_query($query, $link);
				$forcedDays = 0;
								
				while($data1 = mysql_fetch_assoc($r2)) {
					$forcedDays += $data1['Days'];					
				}
				
				if ($forcedDays > 5) {
					$daysError3 = 1;
					$errorFlag = 1;
					$typeOfError = "Forced Leave";
				}
			}
			
			
					
			if (!$errorFlag) {
				LeaveFormView :: requestAddLeave($_POST['dateOfFiling'], 
										 $_POST['dateReceived'], 
										 $_POST['typeOfLeave'], 
										 $_POST['days'], $_POST['startDate'],
										 $_POST['endDate'], $_POST['status'],
										 $_POST['employeeNumber'],
										 $_POST['time']);
				//////////dagdag
				LeaveFormController :: generateLeaveList($_POST['employeeNumber']);
				///////////
			} else {
			
			if(isset($_SESSION['login']) && $_SESSION['login']==true){
			?>
			<html>
				<head>
					<title>Add Leave Form</title>
					<link href="template.css" rel="stylesheet" type="text/css" media="screen" />
					<script language='javascript'>
						function undertimeIsSelected()
						{
							var hoursPrompt = "", minutesPrompt = "";
							if (document.getElementById('typeOfLeave').value == 'UNDERTIME'  || document.getElementById('typeOfLeave').value == 'TARDINESS') {
								do{									
									var x = prompt('Input Hours '+hoursPrompt, 'hours');									
									if(parseInt(x)>12){
										hoursPrompt = ": Maximum hours is 12 hours.";										
									}
									else {										
										if (parseInt(x)<0) {
											hoursPrompt = ": Invalid hours.";										
										} else {
											hoursPrompt = "";										
										}										
									}
								}while(isNaN(x) || x>12 || x<0);
								if(x != null){
									do{
										var y = prompt('Input Minutes '+minutesPrompt, 'minutes');
										if(parseInt(y)>60){
											minutesPrompt = ": Maximum minutes is 60 minutes.";										
										}
										else {
											if (parseInt(y)<0) {
												minutesPrompt = ": Invalid minutes.";										
											} else {
												minutesPrompt = "";										
											}
										}
									}while(isNaN(y) || y>60 || y<0);
									if(y != null){
										var days = (parseInt(60*x) + parseInt(y))/1440;
										if(isNaN(days)) document.getElementById('days').value = '';
										else {
											document.getElementById('days').value = days;
											var d = parseInt(x) + '/' + parseInt(y);
											document.getElementById('time').value=d;
											//var column = document.getElementById('row2').insertCell(8);
											//d = '<input type=\'hidden\' id=\'time\' name=\'time\' value=' + d + '>';
											//column.innerHTML=d;
										}
									}
								}
							} else { document.getElementById('time').value=''; }
						}						
					</script>				
					<script src="jquery.js"></script>		
					<script>
		function registerpage(){
			window.location = "register.php";
		}		
			
		var timeout = 500;
		var closetimer = 0;
		var ddmenuitem = 0;

		function jsddm_open()
		{  jsddm_canceltimer();
		   jsddm_close();
		   ddmenuitem = $(this).find('ul').css('visibility', 'visible');}

		function jsddm_close()
		{  if(ddmenuitem) ddmenuitem.css('visibility', 'hidden');}

		function jsddm_timer()
		{  closetimer = window.setTimeout(jsddm_close, timeout);}

		function jsddm_canceltimer()
		{  if(closetimer)
		   {  window.clearTimeout(closetimer);
			  closetimer = null;}}

		$(document).ready(function()
		{  $('#jsddm > li').bind('mouseover', jsddm_open)
		   $('#jsddm > li').bind('mouseout',  jsddm_timer)});

		document.onclick = jsddm_close;			
		
		$(document).ready(function(){
							   
		   $("a").css({
			'text-decoration':'none',
		   });
		   $("a").hover(function () {
				$(this).css({'text-decoration':'none','font-weight':'bold'});
			  }, function () {
				var cssObj = {
				  'text-decoration':'none',
				  'font-weight':''
				}
				$(this).css(cssObj);
			  });
									   
		   $("#submit").css({
				'background-color':'white',
				'color':'#2F2825'
			});
			$("#submit").hover(function () {
				$(this).css({'background-color' : '#993333','color':'white','font-weight':'bold'});
			  }, function () {
				var cssObj = {
				  'background-color' : 'white',
				  'color' : '#2F2825',
				  'font-weight':''
				}
				$(this).css(cssObj);
			  });				  
				 
		 });
	</script>
				</head>
				<body>
					<div id="header">
						<div id="logo">
							<h1><span>UPLB</span> &nbsp; Leave Application</h1>
							<ul id="jsddm">
								<?php if(isset($_SESSION['login']) && $_SESSION['login']==true) {?>
								<li><a href="#">ACTIONS <span>&#x25BC</span></a>
									<ul>
										<li><a href="AddEmployee.php">Add Employee</a></li>
										<li><a href="searchEmployee.php">Change Employee</a></li>
									</ul>
								</li>
								<li><a href="logout.php">LOG OUT</a>
								</li>
								<?php } ?>
							</ul>
						</div>
					</div>
					<!-- end header -->
					<div id="wrapper">
						<!-- start page -->
						<div id="page">
						<div id="page-bg">
							<div id="sidebar1" class="sidebar">			
							</div>
							<!-- start content -->
							<div id="content">
								<div class="post">				
									<div class="entry">
										<form name='addLeave' method='post' action='validateAdd.php'>
											<table>			
												<tr>								
													<td>Date of Filing <font size='1'>(mm/dd/yyyy)</font></td>
													<td>
														<input type='text' name='dateOfFiling'id='dateOfFiling'maxlength='10' <?php echo "value='$dateOfFiling'"?> />
													</td>
												<?php
													if ($dFError) {
														echo "<td><font color='red' size='2'>Incorrect date of filing.</font></td>";	
													} else {
														echo "<td>&nbsp;</td>";
													}
												?>
												</tr>
												<tr>
													<td>Date Received <font size='1'>(mm/dd/yyyy)</font></td>
													<td>
											<input type='text' name='dateReceived' id='dateReceived'maxlength='10'<?php echo "value='$dateReceived'"?>/>
										</td>
									<?php	
										if ($dRError) {									
											echo "<td><font color='red' size='2'>Incorrect date received.</font></td>";	
											
										} else {		
											if ($dRError2) {
												echo "<td><font color='red' size='2'>Date received is earlier<br />than date of filing.</font></td>";	
											} else {
												echo "<td>&nbsp;</td>";
											}
										}
									?>
									</tr>
									<tr>
										<td>Type of Leave <font size='1'>&nbsp;&nbsp;</font></td>
										<td>
											<select name='typeOfLeave' id='typeOfLeave' onChange='undertimeIsSelected()'>
											<?php
												if($typeOfLeave == "null") {
													echo "<option name='null' value='null' selected='true'>[Select Type]</option>";							
													echo "<option name='SICK_LEAVE' value='SICK_LEAVE'>Sick Leave</option>";							
													echo "<option name='VACATION_LEAVE' value='VACATION_LEAVE'>Vacation Leave&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>";							
													echo "<option name='AWOL' value='AWOL' >Absence Without Leave</option>";		
													echo "<option name='COMPENSATORY' value='COMPENSATORY'  >Compensatory</option>";											
													echo "<option name='FORCED' value='FORCED'  >Forced Leave</option>";
													echo "<option name='MONET_SL' value='MONET_SL'  >Monetization(SL)</option>";
													echo "<option name='MONET_VL' value='MONET_VL'  >Monetization(VL)</option>";
													echo "<option name='PARENTAL' value='PARENTAL'  >Parental Leave</option>";
													echo "<option name='REHABILITATION' value='REHABILITATION'  >Rehabilitation</option>";
													echo "<option name='RE-ENERGIZING' value='RE-ENERGIZING'  >Re-energizing</option>";
													echo "<option name='SPECIAL' value='SPECIAL'  >Special Leave</option>";
													echo "<option name='SUSPENSION' value='SUSPENSION'  >Suspension</option>";
													echo "<option name='TARDINESS' value='TARDINESS'>Tardiness</option>";
													echo "<option name='UNDERTIME' value='UNDERTIME'>Undertime</option>";
													if($gender=='Female'){
														echo "<option name='MATERNAL' value='MATERNAL'>Maternal</option>";
													}else{
														echo "<option name='PATERNAL' value='PATERNAL'>Paternal</option>";
													}
												} else if($typeOfLeave == "SICK_LEAVE") {
													echo "<option name='null' value='null'>[Select Type]</option>";							
													echo "<option name='SICK_LEAVE' value='SICK_LEAVE' selected='true'>Sick Leave</option>";							
													echo "<option name='VACATION_LEAVE' value='VACATION_LEAVE'>Vacation Leave&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>";							
													echo "<option name='AWOL' value='AWOL' >Absence Without Leave</option>";		
													echo "<option name='COMPENSATORY' value='COMPENSATORY'  >Compensatory</option>";											
													echo "<option name='FORCED' value='FORCED'  >Forced Leave</option>";
													echo "<option name='MONET_SL' value='MONET_SL'  >Monetization(SL)</option>";
													echo "<option name='MONET_VL' value='MONET_VL'  >Monetization(VL)</option>";
													echo "<option name='PARENTAL' value='PARENTAL'  >Parental Leave</option>";
													echo "<option name='REHABILITATION' value='REHABILITATION'  >Rehabilitation</option>";
													echo "<option name='RE-ENERGIZING' value='RE-ENERGIZING'  >Re-energizing</option>";
													echo "<option name='SPECIAL' value='SPECIAL'  >Special Leave</option>";
													echo "<option name='SUSPENSION' value='SUSPENSION'  >Suspension</option>";
													echo "<option name='TARDINESS' value='TARDINESS'>Tardiness</option>";
													echo "<option name='UNDERTIME' value='UNDERTIME'>Undertime</option>";
													if($gender=='Female'){
														echo "<option name='MATERNAL' value='MATERNAL'>Maternal</option>";
													}else{
														echo "<option name='PATERNAL' value='PATERNAL'>Paternal</option>";
													}
												} else if ($typeOfLeave == "VACATION_LEAVE") {
													echo "<option name='null' value='null'>[Select Type]</option>";							
													echo "<option name='SICK_LEAVE' value='SICK_LEAVE'>Sick Leave</option>";							
													echo "<option name='VACATION_LEAVE' value='VACATION_LEAVE' selected='true'>Vacation Leave&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>";							
													echo "<option name='AWOL' value='AWOL' >Absence Without Leave</option>";		
													echo "<option name='COMPENSATORY' value='COMPENSATORY'  >Compensatory</option>";											
													echo "<option name='FORCED' value='FORCED'  >Forced Leave</option>";
													echo "<option name='MONET_SL' value='MONET_SL'  >Monetization(SL)</option>";
													echo "<option name='MONET_VL' value='MONET_VL'  >Monetization(VL)</option>";
													echo "<option name='PARENTAL' value='PARENTAL'  >Parental Leave</option>";
													echo "<option name='REHABILITATION' value='REHABILITATION'  >Rehabilitation</option>";
													echo "<option name='RE-ENERGIZING' value='RE-ENERGIZING'  >Re-energizing</option>";
													echo "<option name='SPECIAL' value='SPECIAL'  >Special Leave</option>";
													echo "<option name='SUSPENSION' value='SUSPENSION'  >Suspension</option>";
													echo "<option name='TARDINESS' value='TARDINESS'>Tardiness</option>";
													echo "<option name='UNDERTIME' value='UNDERTIME'>Undertime</option>";
													if($gender=='Female'){
														echo "<option name='MATERNAL' value='MATERNAL'>Maternal</option>";
													}else{
														echo "<option name='PATERNAL' value='PATERNAL'>Paternal</option>";
													}
												} else if ($typeOfLeave == "AWOL") {
													echo "<option name='null' value='null'>[Select Type]</option>";							
													echo "<option name='SICK_LEAVE' value='SICK_LEAVE'>Sick Leave</option>";							
													echo "<option name='VACATION_LEAVE' value='VACATION_LEAVE'>Vacation Leave&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>";							
													echo "<option name='AWOL' value='AWOL' selected='true'>Absence Without Leave</option>";		
													echo "<option name='COMPENSATORY' value='COMPENSATORY'  >Compensatory</option>";											
													echo "<option name='FORCED' value='FORCED'  >Forced Leave</option>";
													echo "<option name='MONET_SL' value='MONET_SL'  >Monetization(SL)</option>";
													echo "<option name='MONET_VL' value='MONET_VL'  >Monetization(VL)</option>";
													echo "<option name='PARENTAL' value='PARENTAL'  >Parental Leave</option>";
													echo "<option name='REHABILITATION' value='REHABILITATION'  >Rehabilitation</option>";
													echo "<option name='RE-ENERGIZING' value='RE-ENERGIZING'  >Re-energizing</option>";
													echo "<option name='SPECIAL' value='SPECIAL'  >Special Leave</option>";
													echo "<option name='SUSPENSION' value='SUSPENSION'  >Suspension</option>";
													echo "<option name='TARDINESS' value='TARDINESS'>Tardiness</option>";
													echo "<option name='UNDERTIME' value='UNDERTIME'>Undertime</option>";
													if($gender=='Female'){
														echo "<option name='MATERNAL' value='MATERNAL'>Maternal</option>";
													}else{
														echo "<option name='PATERNAL' value='PATERNAL'>Paternal</option>";
													}
												} else if ($typeOfLeave == "COMPENSATORY") {
													echo "<option name='null' value='null'>[Select Type]</option>";							
													echo "<option name='SICK_LEAVE' value='SICK_LEAVE'>Sick Leave</option>";							
													echo "<option name='VACATION_LEAVE' value='VACATION_LEAVE'>Vacation Leave&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>";							
													echo "<option name='AWOL' value='AWOL'>Absence Without Leave</option>";		
													echo "<option name='COMPENSATORY' value='COMPENSATORY' selected='true'>Compensatory</option>";											
													echo "<option name='FORCED' value='FORCED'  >Forced Leave</option>";
													echo "<option name='MONET_SL' value='MONET_SL'  >Monetization(SL)</option>";
													echo "<option name='MONET_VL' value='MONET_VL'  >Monetization(VL)</option>";
													echo "<option name='PARENTAL' value='PARENTAL'  >Parental Leave</option>";
													echo "<option name='REHABILITATION' value='REHABILITATION'  >Rehabilitation</option>";
													echo "<option name='RE-ENERGIZING' value='RE-ENERGIZING'  >Re-energizing</option>";
													echo "<option name='SPECIAL' value='SPECIAL'  >Special Leave</option>";
													echo "<option name='SUSPENSION' value='SUSPENSION'  >Suspension</option>";
													echo "<option name='TARDINESS' value='TARDINESS'>Tardiness</option>";
													echo "<option name='UNDERTIME' value='UNDERTIME'>Undertime</option>";
													if($gender=='Female'){
														echo "<option name='MATERNAL' value='MATERNAL'>Maternal</option>";
													}else{
														echo "<option name='PATERNAL' value='PATERNAL'>Paternal</option>";
													}
												} else if ($typeOfLeave == "FORCED") {
													echo "<option name='null' value='null'>[Select Type]</option>";							
													echo "<option name='SICK_LEAVE' value='SICK_LEAVE'>Sick Leave</option>";							
													echo "<option name='VACATION_LEAVE' value='VACATION_LEAVE'>Vacation Leave&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>";							
													echo "<option name='AWOL' value='AWOL'>Absence Without Leave</option>";		
													echo "<option name='COMPENSATORY' value='COMPENSATORY'>Compensatory</option>";											
													echo "<option name='FORCED' value='FORCED' selected='true'>Forced Leave</option>";
													echo "<option name='MONET_SL' value='MONET_SL'  >Monetization(SL)</option>";
													echo "<option name='MONET_VL' value='MONET_VL'  >Monetization(VL)</option>";
													echo "<option name='PARENTAL' value='PARENTAL'  >Parental Leave</option>";
													echo "<option name='REHABILITATION' value='REHABILITATION'  >Rehabilitation</option>";
													echo "<option name='RE-ENERGIZING' value='RE-ENERGIZING'  >Re-energizing</option>";
													echo "<option name='SPECIAL' value='SPECIAL'  >Special Leave</option>";
													echo "<option name='SUSPENSION' value='SUSPENSION'  >Suspension</option>";
													echo "<option name='TARDINESS' value='TARDINESS'>Tardiness</option>";
													echo "<option name='UNDERTIME' value='UNDERTIME'>Undertime</option>";
													if($gender=='Female'){
														echo "<option name='MATERNAL' value='MATERNAL'>Maternal</option>";
													}else{
														echo "<option name='PATERNAL' value='PATERNAL'>Paternal</option>";
													}
												} else if ($typeOfLeave == "MONET_SL") {
													echo "<option name='null' value='null'>[Select Type]</option>";							
													echo "<option name='SICK_LEAVE' value='SICK_LEAVE'>Sick Leave</option>";							
													echo "<option name='VACATION_LEAVE' value='VACATION_LEAVE'>Vacation Leave&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>";							
													echo "<option name='AWOL' value='AWOL'>Absence Without Leave</option>";		
													echo "<option name='COMPENSATORY' value='COMPENSATORY'>Compensatory</option>";											
													echo "<option name='FORCED' value='FORCED'>Forced Leave</option>";
													echo "<option name='MONET_SL' value='MONET_SL' selected='true'  >Monetization(SL)</option>";
													echo "<option name='MONET_VL' value='MONET_VL'  >Monetization(VL)</option>";
													echo "<option name='PARENTAL' value='PARENTAL'  >Parental Leave</option>";
													echo "<option name='REHABILITATION' value='REHABILITATION'  >Rehabilitation</option>";
													echo "<option name='RE-ENERGIZING' value='RE-ENERGIZING'  >Re-energizing</option>";
													echo "<option name='SPECIAL' value='SPECIAL'  >Special Leave</option>";
													echo "<option name='SUSPENSION' value='SUSPENSION'  >Suspension</option>";
													echo "<option name='TARDINESS' value='TARDINESS'>Tardiness</option>";
													echo "<option name='UNDERTIME' value='UNDERTIME'>Undertime</option>";
													if($gender=='Female'){
														echo "<option name='MATERNAL' value='MATERNAL'>Maternal</option>";
													}else{
														echo "<option name='PATERNAL' value='PATERNAL'>Paternal</option>";
													}
												} else if ($typeOfLeave == "MONET_VL") {
													echo "<option name='null' value='null'>[Select Type]</option>";							
													echo "<option name='SICK_LEAVE' value='SICK_LEAVE'>Sick Leave</option>";							
													echo "<option name='VACATION_LEAVE' value='VACATION_LEAVE'>Vacation Leave&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>";							
													echo "<option name='AWOL' value='AWOL'>Absence Without Leave</option>";		
													echo "<option name='COMPENSATORY' value='COMPENSATORY'>Compensatory</option>";											
													echo "<option name='FORCED' value='FORCED'>Forced Leave</option>";
													echo "<option name='MONET_SL' value='MONET_SL'  >Monetization(SL)</option>";
													echo "<option name='MONET_VL' value='MONET_VL' selected='true'  >Monetization(VL)</option>";
													echo "<option name='PARENTAL' value='PARENTAL'  >Parental Leave</option>";
													echo "<option name='REHABILITATION' value='REHABILITATION'  >Rehabilitation</option>";
													echo "<option name='RE-ENERGIZING' value='RE-ENERGIZING'  >Re-energizing</option>";
													echo "<option name='SPECIAL' value='SPECIAL'  >Special Leave</option>";
													echo "<option name='SUSPENSION' value='SUSPENSION'  >Suspension</option>";
													echo "<option name='TARDINESS' value='TARDINESS'>Tardiness</option>";
													echo "<option name='UNDERTIME' value='UNDERTIME'>Undertime</option>";
													if($gender=='Female'){
														echo "<option name='MATERNAL' value='MATERNAL'>Maternal</option>";
													}else{
														echo "<option name='PATERNAL' value='PATERNAL'>Paternal</option>";
													}
												} else if ($typeOfLeave == "PARENTAL") {
													echo "<option name='null' value='null'>[Select Type]</option>";							
													echo "<option name='SICK_LEAVE' value='SICK_LEAVE'>Sick Leave</option>";							
													echo "<option name='VACATION_LEAVE' value='VACATION_LEAVE'>Vacation Leave&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>";							
													echo "<option name='AWOL' value='AWOL'>Absence Without Leave</option>";		
													echo "<option name='COMPENSATORY' value='COMPENSATORY'>Compensatory</option>";											
													echo "<option name='FORCED' value='FORCED'>Forced Leave</option>";
													echo "<option name='MONET_SL' value='MONET_SL'  >Monetization(SL)</option>";
													echo "<option name='MONET_VL' value='MONET_VL'  >Monetization(VL)</option>";
													echo "<option name='PARENTAL' value='PARENTAL' selected='true'  >Parental Leave</option>";
													echo "<option name='REHABILITATION' value='REHABILITATION'  >Rehabilitation</option>";
													echo "<option name='RE-ENERGIZING' value='RE-ENERGIZING'  >Re-energizing</option>";
													echo "<option name='SPECIAL' value='SPECIAL'  >Special Leave</option>";
													echo "<option name='SUSPENSION' value='SUSPENSION'  >Suspension</option>";
													echo "<option name='TARDINESS' value='TARDINESS'>Tardiness</option>";
													echo "<option name='UNDERTIME' value='UNDERTIME'>Undertime</option>";
													if($gender=='Female'){
														echo "<option name='MATERNAL' value='MATERNAL'>Maternal</option>";
													}else{
														echo "<option name='PATERNAL' value='PATERNAL'>Paternal</option>";
													}
												} else if ($typeOfLeave == "REHABILITATION") {
													echo "<option name='null' value='null'>[Select Type]</option>";							
													echo "<option name='SICK_LEAVE' value='SICK_LEAVE'>Sick Leave</option>";							
													echo "<option name='VACATION_LEAVE' value='VACATION_LEAVE'>Vacation Leave&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>";							
													echo "<option name='AWOL' value='AWOL'>Absence Without Leave</option>";		
													echo "<option name='COMPENSATORY' value='COMPENSATORY'>Compensatory</option>";											
													echo "<option name='FORCED' value='FORCED'>Forced Leave</option>";
													echo "<option name='MONET_SL' value='MONET_SL'  >Monetization(SL)</option>";
													echo "<option name='MONET_VL' value='MONET_VL'  >Monetization(VL)</option>";
													echo "<option name='PARENTAL' value='PARENTAL' >Parental Leave</option>";
													echo "<option name='REHABILITATION' value='REHABILITATION' selected='true'   >Rehabilitation</option>";
													echo "<option name='RE-ENERGIZING' value='RE-ENERGIZING'  >Re-energizing</option>";
													echo "<option name='SPECIAL' value='SPECIAL'  >Special Leave</option>";
													echo "<option name='SUSPENSION' value='SUSPENSION'  >Suspension</option>";
													echo "<option name='TARDINESS' value='TARDINESS'>Tardiness</option>";
													echo "<option name='UNDERTIME' value='UNDERTIME'>Undertime</option>";
													if($gender=='Female'){
														echo "<option name='MATERNAL' value='MATERNAL'>Maternal</option>";
													}else{
														echo "<option name='PATERNAL' value='PATERNAL'>Paternal</option>";
													}
												}  else if ($typeOfLeave == "RE-ENERGIZING") {
													echo "<option name='null' value='null'>[Select Type]</option>";							
													echo "<option name='SICK_LEAVE' value='SICK_LEAVE'>Sick Leave</option>";							
													echo "<option name='VACATION_LEAVE' value='VACATION_LEAVE'>Vacation Leave&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>";							
													echo "<option name='AWOL' value='AWOL'>Absence Without Leave</option>";		
													echo "<option name='COMPENSATORY' value='COMPENSATORY'>Compensatory</option>";											
													echo "<option name='FORCED' value='FORCED'>Forced Leave</option>";
													echo "<option name='MONET_SL' value='MONET_SL'  >Monetization(SL)</option>";
													echo "<option name='MONET_VL' value='MONET_VL'  >Monetization(VL)</option>";
													echo "<option name='PARENTAL' value='PARENTAL' >Parental Leave</option>";
													echo "<option name='REHABILITATION' value='REHABILITATION' >Rehabilitation</option>";
													echo "<option name='RE-ENERGIZING' value='RE-ENERGIZING' selected='true'  >Re-energizing</option>";
													echo "<option name='SPECIAL' value='SPECIAL'  >Special Leave</option>";
													echo "<option name='SUSPENSION' value='SUSPENSION'  >Suspension</option>";
													echo "<option name='TARDINESS' value='TARDINESS'>Tardiness</option>";
													echo "<option name='UNDERTIME' value='UNDERTIME'>Undertime</option>";
													if($gender=='Female'){
														echo "<option name='MATERNAL' value='MATERNAL'>Maternal</option>";
													}else{
														echo "<option name='PATERNAL' value='PATERNAL'>Paternal</option>";
													}
												}  else if ($typeOfLeave == "SPECIAL") {
													echo "<option name='null' value='null'>[Select Type]</option>";							
													echo "<option name='SICK_LEAVE' value='SICK_LEAVE'>Sick Leave</option>";							
													echo "<option name='VACATION_LEAVE' value='VACATION_LEAVE'>Vacation Leave&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>";							
													echo "<option name='AWOL' value='AWOL'>Absence Without Leave</option>";		
													echo "<option name='COMPENSATORY' value='COMPENSATORY'>Compensatory</option>";											
													echo "<option name='FORCED' value='FORCED'>Forced Leave</option>";
													echo "<option name='MONET_SL' value='MONET_SL'  >Monetization(SL)</option>";
													echo "<option name='MONET_VL' value='MONET_VL'  >Monetization(VL)</option>";
													echo "<option name='PARENTAL' value='PARENTAL' >Parental Leave</option>";
													echo "<option name='REHABILITATION' value='REHABILITATION' >Rehabilitation</option>";
													echo "<option name='RE-ENERGIZING' value='RE-ENERGIZING'>Re-energizing</option>";
													echo "<option name='SPECIAL' value='SPECIAL' selected='true' >Special Leave</option>";
													echo "<option name='SUSPENSION' value='SUSPENSION'  >Suspension</option>";
													echo "<option name='TARDINESS' value='TARDINESS'>Tardiness</option>";
													echo "<option name='UNDERTIME' value='UNDERTIME'>Undertime</option>";
													if($gender=='Female'){
														echo "<option name='MATERNAL' value='MATERNAL'>Maternal</option>";
													}else{
														echo "<option name='PATERNAL' value='PATERNAL'>Paternal</option>";
													}
												}  else if ($typeOfLeave == "SUSPENSION") {
													echo "<option name='null' value='null'>[Select Type]</option>";							
													echo "<option name='SICK_LEAVE' value='SICK_LEAVE'>Sick Leave</option>";							
													echo "<option name='VACATION_LEAVE' value='VACATION_LEAVE'>Vacation Leave&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>";							
													echo "<option name='AWOL' value='AWOL'>Absence Without Leave</option>";		
													echo "<option name='COMPENSATORY' value='COMPENSATORY'>Compensatory</option>";											
													echo "<option name='FORCED' value='FORCED'>Forced Leave</option>";
													echo "<option name='MONET_SL' value='MONET_SL'  >Monetization(SL)</option>";
													echo "<option name='MONET_VL' value='MONET_VL'  >Monetization(VL)</option>";
													echo "<option name='PARENTAL' value='PARENTAL' >Parental Leave</option>";
													echo "<option name='REHABILITATION' value='REHABILITATION' >Rehabilitation</option>";
													echo "<option name='RE-ENERGIZING' value='RE-ENERGIZING'>Re-energizing</option>";
													echo "<option name='SPECIAL' value='SPECIAL'>Special Leave</option>";
													echo "<option name='SUSPENSION' value='SUSPENSION' selected='true' >Suspension</option>";
													echo "<option name='TARDINESS' value='TARDINESS'>Tardiness</option>";
													echo "<option name='UNDERTIME' value='UNDERTIME'>Undertime</option>";
													if($gender=='Female'){
														echo "<option name='MATERNAL' value='MATERNAL'>Maternal</option>";
													}else{
														echo "<option name='PATERNAL' value='PATERNAL'>Paternal</option>";
													}
												}  else if ($typeOfLeave == "TARDINESS") {
													echo "<option name='null' value='null'>[Select Type]</option>";							
													echo "<option name='SICK_LEAVE' value='SICK_LEAVE'>Sick Leave</option>";							
													echo "<option name='VACATION_LEAVE' value='VACATION_LEAVE'>Vacation Leave&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>";							
													echo "<option name='AWOL' value='AWOL'>Absence Without Leave</option>";		
													echo "<option name='COMPENSATORY' value='COMPENSATORY'>Compensatory</option>";											
													echo "<option name='FORCED' value='FORCED'>Forced Leave</option>";
													echo "<option name='MONET_SL' value='MONET_SL'  >Monetization(SL)</option>";
													echo "<option name='MONET_VL' value='MONET_VL'  >Monetization(VL)</option>";
													echo "<option name='PARENTAL' value='PARENTAL' >Parental Leave</option>";
													echo "<option name='REHABILITATION' value='REHABILITATION' >Rehabilitation</option>";
													echo "<option name='RE-ENERGIZING' value='RE-ENERGIZING'>Re-energizing</option>";
													echo "<option name='SPECIAL' value='SPECIAL'>Special Leave</option>";
													echo "<option name='SUSPENSION' value='SUSPENSION' >Suspension</option>";
													echo "<option name='TARDINESS' value='TARDINESS' selected='true'>Tardiness</option>";
													echo "<option name='UNDERTIME' value='UNDERTIME'>Undertime</option>";
													if($gender=='Female'){
														echo "<option name='MATERNAL' value='MATERNAL'>Maternal</option>";
													}else{
														echo "<option name='PATERNAL' value='PATERNAL'>Paternal</option>";
													}
												}  else if ($typeOfLeave == "UNDERTIME") {
													echo "<option name='null' value='null'>[Select Type]</option>";							
													echo "<option name='SICK_LEAVE' value='SICK_LEAVE'>Sick Leave</option>";							
													echo "<option name='VACATION_LEAVE' value='VACATION_LEAVE'>Vacation Leave&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>";							
													echo "<option name='AWOL' value='AWOL'>Absence Without Leave</option>";		
													echo "<option name='COMPENSATORY' value='COMPENSATORY'>Compensatory</option>";											
													echo "<option name='FORCED' value='FORCED'>Forced Leave</option>";
													echo "<option name='MONET_SL' value='MONET_SL'  >Monetization(SL)</option>";
													echo "<option name='MONET_VL' value='MONET_VL'  >Monetization(VL)</option>";
													echo "<option name='PARENTAL' value='PARENTAL' >Parental Leave</option>";
													echo "<option name='REHABILITATION' value='REHABILITATION' >Rehabilitation</option>";
													echo "<option name='RE-ENERGIZING' value='RE-ENERGIZING'>Re-energizing</option>";
													echo "<option name='SPECIAL' value='SPECIAL'>Special Leave</option>";
													echo "<option name='SUSPENSION' value='SUSPENSION' >Suspension</option>";
													echo "<option name='TARDINESS' value='TARDINESS'>Tardiness</option>";
													echo "<option name='UNDERTIME' value='UNDERTIME' selected='true'>Undertime</option>";
													if($gender=='Female'){
														echo "<option name='MATERNAL' value='MATERNAL'>Maternal</option>";
													}else{
														echo "<option name='PATERNAL' value='PATERNAL'>Paternal</option>";
													}
												}  else if ($typeOfLeave == "MATERNAL") {
													echo "<option name='null' value='null'>[Select Type]</option>";							
													echo "<option name='SICK_LEAVE' value='SICK_LEAVE'>Sick Leave</option>";							
													echo "<option name='VACATION_LEAVE' value='VACATION_LEAVE'>Vacation Leave&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>";							
													echo "<option name='AWOL' value='AWOL'>Absence Without Leave</option>";		
													echo "<option name='COMPENSATORY' value='COMPENSATORY'>Compensatory</option>";											
													echo "<option name='FORCED' value='FORCED'>Forced Leave</option>";
													echo "<option name='MONET_SL' value='MONET_SL'  >Monetization(SL)</option>";
													echo "<option name='MONET_VL' value='MONET_VL'  >Monetization(VL)</option>";
													echo "<option name='PARENTAL' value='PARENTAL' >Parental Leave</option>";
													echo "<option name='REHABILITATION' value='REHABILITATION' >Rehabilitation</option>";
													echo "<option name='RE-ENERGIZING' value='RE-ENERGIZING'>Re-energizing</option>";
													echo "<option name='SPECIAL' value='SPECIAL'>Special Leave</option>";
													echo "<option name='SUSPENSION' value='SUSPENSION' >Suspension</option>";
													echo "<option name='TARDINESS' value='TARDINESS'>Tardiness</option>";
													echo "<option name='UNDERTIME' value='UNDERTIME'>Undertime</option>";
													echo "<option name='MATERNAL' value='MATERNAL' selected='true'>Maternal</option>";
												}  else if ($typeOfLeave == "PATERNAL") {
													echo "<option name='null' value='null'>[Select Type]</option>";							
													echo "<option name='SICK_LEAVE' value='SICK_LEAVE'>Sick Leave</option>";							
													echo "<option name='VACATION_LEAVE' value='VACATION_LEAVE'>Vacation Leave&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>";							
													echo "<option name='AWOL' value='AWOL'>Absence Without Leave</option>";		
													echo "<option name='COMPENSATORY' value='COMPENSATORY'>Compensatory</option>";											
													echo "<option name='FORCED' value='FORCED'>Forced Leave</option>";
													echo "<option name='MONET_SL' value='MONET_SL'  >Monetization(SL)</option>";
													echo "<option name='MONET_VL' value='MONET_VL'  >Monetization(VL)</option>";
													echo "<option name='PARENTAL' value='PARENTAL' >Parental Leave</option>";
													echo "<option name='REHABILITATION' value='REHABILITATION' >Rehabilitation</option>";
													echo "<option name='RE-ENERGIZING' value='RE-ENERGIZING'>Re-energizing</option>";
													echo "<option name='SPECIAL' value='SPECIAL'>Special Leave</option>";
													echo "<option name='SUSPENSION' value='SUSPENSION' >Suspension</option>";
													echo "<option name='TARDINESS' value='TARDINESS'>Tardiness</option>";
													echo "<option name='UNDERTIME' value='UNDERTIME'>Undertime</option>";
													echo "<option name='PATERNAL' value='PATERNAL' selected='true'>Paternal</option>";
												}  
												
											?>															
											</select>
										</td>
									<?php		
										if ($tLError) {
											echo "<td><font color='red' size='2'>No type of leave selected.</font></td>";
										} else {
											//print nothing sa error ROW
											echo "<td>&nbsp;</td>";
										}
									?>
									</tr>
									<tr>

										<td>Days <font size='1'>&nbsp;&nbsp;</font></td>
										<td>
											<input type='text' name='days' id='days' maxlength='2'<?php echo "value='$days'"?>/>
										</td>
									<?php
										if ($daysError) {
											echo "<td><font color='red' size='2'>Days empty.</font></td>";
										} else {
											//print nothing sa error ROW
											if ($daysError2) {
												echo "<td><font color='red' size='2'>Incorrect days.</font></td>";
											}else {
												if ($daysError3) {
													echo "<td><font color='red' size='2'>".$typeOfError." days exceeded.</font></td>";
												} else {
													echo "<td>&nbsp;</td>";
												}
											}
										}
									?>
									</tr>
									<tr>
										<td>Start Date <font size='1'>(mm/dd/yyyy)</font></td>
										<td>
											<input type='text' name='startDate' id='startDate'maxlength='10' <?php echo "value='$startDate'"?>/>
										</td>
									<?php
										if ($sDError) {
											echo "<td><font color='red' size='2'>Incorrect start date.</font></td>";												
										}  
										else {							
											if ($sDError2) {
												echo "<td><font color='red' size='2'>Start date conflicts previous leave.</font></td>";												
											} else {
											//print nothing sa error ROW
												echo "<td>&nbsp;</td>";
											}
										}
									?>
									</tr>
									<tr>
										<td>End Date <font size='1'>(mm/dd/yyyy)</font></td>
										<td>
											<input type='text' name='endDate' id='endDate'maxlength='10'<?php echo "value='$endDate'"?>/>
										</td>
									<?php
										if ($eDError) {
											echo "<td><font color='red' size='2'>Incorrect end date.</font></td>";
										} else {
											if ($eDError2) {
												echo "<td><font color='red' size='2'>End date is earlier<br />than start date.</font></td>";
											} else {						
												if ($eDError3) {
													echo "<td><font color='red' size='2'>End date conflicts previous leave.</font></td>";												
												} else {//print nothing sa error ROW
													echo "<td>&nbsp;</td>";
												}
											}
										}
									?>
									</tr>
									<tr>
										<td>Status <font size='1'>&nbsp;&nbsp;</font></td>
										<td>
											<select name='status' id='status'>
											<?php
												if ($status == "null") {
													echo "<option name='null' value='null' selected='true'>[Select Type]</option>";
												} else {
													echo "<option name='null' value='null'>[Select Type]</option>";
												}
												if ($status == "WITH_PAY") {
													echo "<option name='WITH_PAY' value='WITH_PAY' selected='true'>Approved With Pay</option>";
												} else {
													echo "<option name='WITH_PAY' value='WITH_PAY'>Approved With Pay</option>";
												}
												if ($status == "WITHOUT_PAY") {
													echo "<option name='WITHOUT_PAY' value='WITHOUT_PAY' selected='true'>Approved Without Pay</option>";
												} else {
													echo "<option name='WITHOUT_PAY' value='WITHOUT_PAY'>Approved Without Pay</option>";
												}
												
											?>	
											</select>
										</td>
									<?php
										if ($sError) {
											echo "<td><font color='red' size='2'>No type of status selected.</font></td>";
										} else {
											echo "<td>&nbsp;</td>";
										}
									?>	
									</tr>
									<tr>
											<td>
											<input type='hidden' name='employeeNumber' id='employeeNumber' value='<?php echo $employeeNumber; ?>' />								
											<input type='hidden' name='time' id='time' value=''/>
										</td>
									</tr>
									<tr>
										<td><input type='submit' name='submitAddLeave'/></td>
									</tr>
								</table> 
								
							</form>
							<p class="links"><a href='menu.php' class="more">&laquo;&laquo;&nbsp;&nbsp;Home&nbsp;&nbsp;&raquo;&raquo;</a></p>					
						</div>
					</div>
				</div>
				<!-- end content -->
				<!-- start sidebars -->
				<div id="sidebar2" class="sidebar">
				</div>
				<!-- end sidebars -->
				<div style="clear: both;">&nbsp;</div>
			</div>
			</div>
			<!-- end page -->
		</div>
		<div id="footer">	
		</div>
		</body>
</html>
	
<?php 
		}else
			header("Location: menu.php");
	} 
		?>
